<%-- 
    Document   : calculatorMark
    Created on : Oct 17, 2009, 2:41:53 AM
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.sql.*" %>
<%@taglib prefix="ajax" uri="http://ajaxtags.org/tags/ajax" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <jsp:include page="header.jsp" />
        <link rel="stylesheet" href="css/style.css" />
        <link rel="stylesheet" href="css/front.css"  />

        <title>Themes</title>
    </head>
    <body bgcolor="#154978">

        <jsp:useBean id="ObjTest" class="DAO.Result" scope="request" />
        <%
            float mark = Float.parseFloat(request.getParameter("Mark"));
            int answerTrue = Integer.parseInt(request.getParameter("AnswerTrue"));
            int TestID = Integer.parseInt(request.getParameter("TestID"));
            String UserName = session.getAttribute("UserName").toString();
            String StartTime = request.getParameter("StartTime");
            String EndTime = request.getParameter("EndTime");
            int status = Integer.parseInt(request.getParameter("Status"));
          //  out.println(mark);
         //   out.println(answerTrue);
         //   out.println(TestID);
         //   out.println(UserName);
         //   out.println(StartTime);
         //   out.println(EndTime);
        //    out.println(status);

           if(ObjTest.InsertResult(TestID, UserName, StartTime, EndTime, answerTrue, mark, status) == true){
            out.println("Thanh cong");
           }else{
           out.println("khong thanh cong");
           }
        %>
        <%
            ResultSet rst = null;
           rst = ObjTest.selectResult();
           int id = 0;
            while (rst.next()) {
                id = rst.getInt("ResultID");

           }out.println(id);

            int idQuestionInsert = 0;
            int idAnswerInsert = 0;
            String[] QuestionID = request.getParameterValues("QuestionID");
           // for (int i = 0; i < QuestionID.length; i++) {
            //    idQuestionInsert = Integer.parseInt(QuestionID[i]);
                //   out.println(idQuestionInsert);

           // }

            String[] idAnswer = request.getParameterValues("choiceUser");
            for (int i = 0; i < idAnswer.length; i++) {
                //out.println(idAnswer[i] +"<br>");
                idAnswerInsert = Integer.parseInt(idAnswer[i]);
                // out.println(idAnswerInsert);
                ObjTest.insertDetail(id, QuestionID, idAnswerInsert);
            }

        %>


        <%
            /*
            ResultSet rs1 = null;
            ResultSet rs2 = null;
            ResultSet rs3 = null;
            ResultSet rs4 = null;
            int idQuestionResult ;
            String ConntentQuestion ;
            rs1 = ObjTest.selectQuestion(id);
            while (rs1.next()) {
            idQuestionResult  = rs1.getInt("QuestionID");
            rs2 = ObjTest.selectQuestionContent(idQuestionResult);
            while(rs2.next()){
            ConntentQuestion = rs2.getString("ContentQuestion");

            }
            }
             */
            //ResultSet rsu = null;
        %>

    </body>
</html>
